Java Servlet Architecture:

There are two packages for servlet architecture.

javax.servlet.*;
javax.servlet.http.*;

 

 

 

 

 

 

 

 

The Frame Work of the Servlets:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Types of Servlets:
1. Generic Servlet
2. Http Servlet

   The Http servlet class is extended from Generic Servlet when you are developing your own servlets you will most likely extended one of these two classes.
Java Servlets don’t have main method.
If you extend the servlet class you must implement the service method.

Syntax:
public abstract void service(ServletRequest req,ServletResponse res) throws ServletException,IOException

 

Implementation of the Generic Servlet:-

 

 

 


 Unlike the Generic servlet when you extend the Http servlet you don’t usually implement the service method is invoke it reads the method type is stored in the request and determines which method to  invoke based on these values. If the method is get it will call doGet(),If the method is post it will call doPost().